﻿namespace _2.Data_Access_Object
{
	using _1.Maping_all_tables_in_DB_First;

	internal class EmployeeDAO // https://cgeers.wordpress.com/2009/03/14/data-access-objects-with-the-entity-framework/
	{
		private static SoftUniEntities databaseContext = new SoftUniEntities();

		public EmployeeDAO()
		{
			
		}

		internal static void Add(Employee employee)
		{
			databaseContext.Employees.Add(employee);

			databaseContext.SaveChanges();
		}

		internal static Employee FindByKey(object key)
		{
			return databaseContext.Employees.Find(key);
		}

		internal static void Modify(Employee employee)
		{
			databaseContext.Entry(employee).State = System.Data.Entity.EntityState.Modified;

			databaseContext.SaveChanges();
		}

		internal static void Delete(Employee employee)
		{
			databaseContext.Employees.Remove(employee);

			databaseContext.SaveChanges();
		}
	}
}